package eleven;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPTypeServer {
    public static void main(String[] args) throws Exception {
        System.out.println("UDPServer 启动中...");
        DatagramSocket server = new DatagramSocket(9999);
        byte[] container = new byte[1024 * 60];
        DatagramPacket packet = new DatagramPacket(container, 0, container.length);
        server.receive(packet);
        byte[] datas = packet.getData();
        int len = packet.getLength();
        DataInputStream dis = new DataInputStream(new BufferedInputStream(
                new ByteArrayInputStream(datas, 0, len)));
        String msg = dis.readUTF();
        int age = dis.readInt();
        boolean flag = dis.readBoolean();
        char ch = dis.readChar();
        System.out.println(msg + "--->" + flag);
        System.out.println(age + "--->" + ch);
        server.close();
    }
}
